package at.fhooe.mc.duel_game.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import at.fhooe.mc.duel_game.R;

public class SplashScreen extends Activity
{
	
	private Thread	mSplashThread;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.layout_splashscreen);
		
		// The thread to wait for splash screen events
		mSplashThread = new Thread()
		{
			@Override
			public void run()
			{
				try
				{
					synchronized (this)
					{
						// Wait given period of time or exit on touch
						wait(5000);
					}
				} catch (InterruptedException ex)
				{
				}
				
				finish();
				
				// Run next activity
				Intent intent = new Intent(getApplicationContext(), at.fhooe.mc.duel_game.activities.MainMenuActivity.class);
				startActivity(intent);
				
			}
		};
		
		mSplashThread.start();
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent evt)
	{
		if (evt.getAction() == MotionEvent.ACTION_DOWN)
		{
			synchronized (mSplashThread)
			{
				mSplashThread.notifyAll();
			}
		}
		return true;
	}
}